<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue-监听器</title>
</head>
<body>

<div id="app">

  <input type="text" v-model="message">
  <input type="text" v-model="firstName">
  <input type="text" v-model="lastName">
  {{fullName}}
</div>

</body>
<script src="../../lib/vue.global.js"></script>
<script>

  /**
   *  监听器的作用
   *     处理异步请求
   * */

   var app= Vue.createApp({
       data:function (){
         return {
           message:'hello',
           firstName:'Martin',
           lastName:'Green',
           fullName:''
         }

       },
     watch:{

         message:function (newVal,oldVal){

             console.log(newVal);
             console.log(oldVal);
         },
         firstName:function (newVal){

             this.fullName = newVal + this.lastName;

         }
     }
    })

   app.mount('#app');

</script>
</html>